<?php
$query = "select * from authToRelease  where  consumer_id = ".$id;
$result = mysql_query($query);
if($row = mysql_fetch_array($result)) {
	$agency1 = $row["agency1"];
	$agency2 = $row["agency2"];
	$agency3 = $row["agency3"];
	$agency4 = $row["agency4"];
	$agency5 = $row["agency5"];
	$person1 = $row["person1"];
	$person2 = $row["person2"];
	$person3 = $row["person3"];
	$person4 = $row["person4"];
	$person5 = $row["person5"];
	$consumerSig = $row["consumer_signature"];
	$consumerSigDate = $row["consumer_signature_date"];
	$guardianSig = $row["guardian_signature"];
	$guardianSigDate = $row["guardian_signature_date"];
	#new for VAIL
	$witnessSig = $row["witness_signature"];
	$employeeSig = $row["employee_signature"];	
	
	if($guardianSigDate) {
		$guardianSigDateMonth = substr($guardianSigDate, 5, 2);
		$guardianSigDateDay = substr($guardianSigDate, 8, 2);
		$guardianSigDateYear = substr($guardianSigDate, 0, 4);
	}
	if($consumerSigDate) {
		$consumerSigDateMonth = substr($consumerSigDate, 5, 2);
		$consumerSigDateDay = substr($consumerSigDate, 8, 2);
		$consumerSigDateYear = substr($consumerSigDate, 0, 4);
	}

} else {
	$guardianSigDateMonth = date("m", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
	$guardianSigDateDay = date("d", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
	$guardianSigDateYear = date("Y", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
	
	$consumerSigDateMonth = date("m", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
	$consumerSigDateDay = date("d", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
	$consumerSigDateYear = date("Y", mktime(date("H"),date("i"),date("s"),date("m"), date("d"), date("Y")));
}
?>

<form action="actions/ProcessAuthToRelease.php" method="post" id="authorizationtorelease">
<h2>Authorization to Release Information Form</h2>
<!-- CONSUMER STATEMENT -->
<table width="100%">
  <tbody>
    <tr>
      <!-- AUTHORIZATION STATEMENT -->
      <td colspan="2"><div class="formUnitVertical">
          <h3> IN SIGNING THIS DOCUMENT, I UNDERSTAND THAT: </h3>
        </div></td>
    </tr>
    <tr>
      <td colspan="2"><div class="formUnitVertical">
          <label for="authorizationStatement2"> I authorize the following agencies, institutions and/or individuals: </label>
        </div></td>
    </tr>
    <!-- AUTHORIZED CONTACTS -->
    <tr>
      <td colspan="2"><!-- NESTED TABLE to hold more than one data element in a cell -->
        <table width="100%">
          <tbody>
            <tr>
              <th>AGENCY</th>
              <th>AUTHORIZED PERSON(S)</th>
            </tr>
            <!-- CONTACT 1 -->
            <tr>
              <td><div class="formUnitVertical">
                  <label for="authorizedAgency1">1a:</label>
                  <input name="agency1" value="<?php echo $agency1 ?>" type="text">
                </div></td>
              <td><div class="formUnitVertical">
                  <label for="authorizedPerson1">1b:</label>
                  <input name="person1" value="<?php echo $person1 ?>" type="text">
                </div></td>
            </tr>
            <!-- CONTACT 2 -->
            <tr>
              <td><div class="formUnitVertical">
                  <label for="authorizedAgency2">2a:</label>
                  <input name="agency2" value="<?php echo $agency2 ?>" type="text">
                </div></td>
              <td><div class="formUnitVertical">
                  <label for="authorizedPerson2">2b:</label>
                  <input name="person2" value="<?php echo $person2 ?>" type="text">
                </div></td>
            </tr>
            <!-- CONTACT 3 -->
            <tr>
              <td><div class="formUnitVertical">
                  <label for="authorizedAgency3">3a:</label>
                  <input name="agency3" value="<?php echo $agency3 ?>" type="text">
                </div></td>
              <td><div class="formUnitVertical">
                  <label for="authorizedPerson3">3b:</label>
                  <input name="person3" value="<?php echo $person3 ?>" type="text">
                </div></td>
            </tr>
            <!-- CONTACT 4 -->
            <tr>
              <td><div class="formUnitVertical">
                  <label for="authorizedAgency4">4a:</label>
                  <input name="agency4" value="<?php echo $agency4 ?>" type="text">
                </div></td>
              <td><div class="formUnitVertical">
                  <label for="authorizedPerson4">4b:</label>
                  <input name="person4" value="<?php echo $person4 ?>" type="text">
                </div></td>
            </tr>
            <!-- CONTACT 5 -->
            <tr>
              <td><div class="formUnitVertical">
                  <label for="authorizedAgency5">5a:</label>
                  <input name="agency5" value="<?php echo $agency5 ?>" type="text">
                </div></td>
              <td><div class="formUnitVertical">
                  <label for="authorizedPerson5">5b:</label>
                  <input name="person5" value="<?php echo $person5 ?>" type="text">
                </div></td>
            </tr>
          </tbody>
        </table></td>
    </tr>
    <tr>
      <td colspan="2"><div class="formUnitVertical">
          <h3>Terms of Release</h3>
        </div></td>
    </tr>
    <tr>
      <td colspan="2"><div class="formUnitVertical">
          <ul>
            <li> To release any and all information (including but not limited to:  
              medical, psychological, vocational, social, or educational evaluations
              and reports) to the agencies and persons listed above. </li>
            <li> I authorize <?php echo THIS_CIL;?> to disclose records pertaining to me to the offices
              and division within the Texas Department of Aging and Rehabilitative Services,
              or any organization or individual having a valid reason signed by me. </li>
            <li> I authorize <?php echo THIS_CIL;?> to discuss pertinent information regarding direct service
              delivery as related to my Independent Living Plan. </li>
            <li> This consent to disclosure is subject to revocation at any time by my written
              notice except to the extent that action has been taken in reliance there on.  
              I further authorize that a photocopy of this authorization form can be fully
              accepted as an original. </li>
            <li> I understand that funding compliance may require the disclosure of information
              related to services provided through this agency. </li>
          </ul>
        </div></td>
    </tr>
    <tr>
      <td colspan="2"><h3>Consumer Direction</h3></td>
    </tr>
    <tr>
      <!-- CONSUMER SIG -->
      <td><div class="formUnitVertical">
          <label for="consumerSignature1">Consumer Signature:</label>
          <br>
          <input name="consumerSignature" value="<?php echo $consumerSig ?>" type="text">
        </div></td>
      <!-- DATE OF SIG : CONSUMER -->
      <td><div class="formUnitVertical">
          <label for="consumerSigDate">Date</label>
          <br>
          <select name="consumerSigDateMonth" id="consumerSigDateMonth">
            <option value="01">January</option>
            <option value="02">February</option>
            <option value="03">March</option>
            <option value="04">April</option>
            <option value="05">May</option>
            <option value="06">June</option>
            <option value="07">July</option>
            <option value="08">August</option>
            <option value="09">September</option>
            <option value="10">October</option>
            <option value="11">November</option>
            <option value="12">December</option>
          </select>
          <script>					
			     for(i=0; i<$('consumerSigDateMonth').options.length; i++) {
			        if($('consumerSigDateMonth').options[i].value=='<? echo $consumerSigDateMonth ?>') {
					   $('consumerSigDateMonth').options[i].selected = true;
				  }
			     }
			  </script>
          <select name="consumerSigDateDay" id="consumerSigDateDay">
            <option value="01">1</option>
            <option value="02">2</option>
            <option value="03">3</option>
            <option value="04">4</option>
            <option value="05">5</option>
            <option value="06">6</option>
            <option value="07">7</option>
            <option value="08">8</option>
            <option value="09">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
          </select>
          <script>					
			     for(i=0; i<$('consumerSigDateDay').options.length; i++) {
					if($('consumerSigDateDay').options[i].value=='<? echo $consumerSigDateDay ?>') {
						$('consumerSigDateDay').options[i].selected = true;
					}
				}
			  </script>
          <select name="consumerSigDateYear" id="consumerSigDateYear">
            <option value="2007">2007</option>
            <option value="2006">2006</option>
            <option value="2005">2005</option>
            <option value="2004">2004</option>
            <option value="2003">2003</option>
            <option value="2002">2002</option>
            <option value="2001">2001</option>
            <option value="2000">2000</option>
            <option value="1999">1999</option>
            <option value="1998">1998</option>
          </select>
          <script>					
			      for(i=0; i<$('consumerSigDateYear').options.length; i++) {
					if($('consumerSigDateYear').options[i].value=='<? echo $consumerSigDateYear ?>') {
						$('consumerSigDateYear').options[i].selected = true;
					}
				}
			  </script>
        </div></td>
    </tr>
    <tr>
      <!-- GUARDIAN SIG -->
      <td><div class="formUnitVertical">
          <label for="guardianSignature">Guardian Signature:</label>
          <br>
          <input name="guardianSignature" value="<?php echo $guardianSig ?>" type="text">
        </div></td>
      <!-- DATE OF SIG : GUARDIAN -->
      <td><div class="formUnitVertical">
          <label for="guardianSigDate">Date</label>
          <br>
          <select name="guardianSigDateMonth" id="guardianSigDateMonth">
            <option value="01">January</option>
            <option value="02">February</option>
            <option value="03">March</option>
            <option value="04">April</option>
            <option value="05">May</option>
            <option value="06">June</option>
            <option value="07">July</option>
            <option value="08">August</option>
            <option value="09">September</option>
            <option value="10">October</option>
            <option value="11">November</option>
            <option value="12">December</option>
          </select>
          <script>					
			     for(i=0; i<$('guardianSigDateMonth').options.length; i++) {
			        if($('guardianSigDateMonth').options[i].value=='<? echo $guardianSigDateMonth ?>') {
					   $('guardianSigDateMonth').options[i].selected = true;
				  }
			     }
			  </script>
          <select name="guardianSigDateDay" id="guardianSigDateDay">
            <option value="01">1</option>
            <option value="02">2</option>
            <option value="03">3</option>
            <option value="04">4</option>
            <option value="05">5</option>
            <option value="06">6</option>
            <option value="07">7</option>
            <option value="08">8</option>
            <option value="09">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
          </select>
          <script>					
			     for(i=0; i<$('guardianSigDateDay').options.length; i++) {
					if($('guardianSigDateDay').options[i].value=='<? echo $guardianSigDateDay ?>') {
						$('guardianSigDateDay').options[i].selected = true;
					}
				}
			  </script>
          <select name="guardianSigDateYear" id="guardianSigDateYear">
            <option value="2007">2007</option>
            <option value="2006">2006</option>
            <option value="2005">2005</option>
            <option value="2004">2004</option>
            <option value="2003">2003</option>
            <option value="2002">2002</option>
            <option value="2001">2001</option>
            <option value="2000">2000</option>
            <option value="1999">1999</option>
            <option value="1998">1998</option>
          </select>
          <script>					
			      for(i=0; i<$('guardianSigDateYear').options.length; i++) {
					if($('guardianSigDateYear').options[i].value=='<? echo $guardianSigDateYear ?>') {
						$('guardianSigDateYear').options[i].selected = true;
					}
				}
			  </script>
        </div></td>
    </tr>
	<tr>
			<!-- WITNESS SIG -->
			<td>
				<div class="formUnitVertical">
					<label for="witnessSignature">Witness Signature:</label>
					<br>
					<input name="witnessSignature" value="<?php echo $witnessSig ?>" type="text">
				</div>
			</td>
	</tr>
    <tr>
      <!-- EMPLOYEE SIGNOFF -->
      <td><div class="formUnitVertical">
          <label for="employee2">Employee Signature:</label>
          <br>
          <input name="employeeSignature" value="<?php echo $employeeSig ?>" type="text">
        </div></td>
      <td align="right"><input value="<?php echo $id ?>" name="id" type="hidden">
        <input class="btn" value="Submit" type="submit">
        <input class="btn" value="Cancel" onClick="window.location='admin.php?action=cieedit&id=<?php echo $id?>';" type="button">
      </td>
    </tr>
  </tbody>
</table>
